package com.zj.student.demo.controller;

import com.zj.student.demo.entity.Student;
import com.zj.student.demo.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("student")
public class StudentController {

    @Autowired
    private StudentService service;

    @PostMapping("/add")
    public String save(Student o) {
        service.save(o);
        return "true";
    }

    @GetMapping("/all")
    public List<Student> all() {
        return service.all();
    }

}
